<?php

namespace App\Admin\Models;

use Illuminate\Database\Eloquent\Model;

class AdminPermission extends Model
{
    protected $table = 'admin_permissions';

    protected $fillable = ['name', 'description'];

    // 权限关联的所有角色
    public function roles()
    {
        return $this->belongsToMany(AdminRole::class, 'admin_role_permissions', 'permission_id', 'role_id')->withPivot(['role_id', 'permission_id']);
    }

}
